<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<link href="<%=request.getContextPath()%>/css/tabcard.css"
	rel="stylesheet" type="text/css">
<script type='text/javascript'
	src='<%=request.getContextPath()%>/dwr/interface/studentAction.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/dwr/interface/dormitoryStatusViewAction.js'></script>
<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/cardAction.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/dwr/util.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/js/commonValidate.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/js/tabcard.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/js/noConflictOfJquery.js'></script>

<script type='text/javascript'>
/*
*包涵该页面
*给$('student_info').value赋值
*调用stu_BasicInfo()
*/
//==================全局变量================
var stuno_bs;   //bs = basic student.  学号
var studentdormitorytype = -1;//与dormitoryconcretefuncid对应,宿舍具体功能代码
//------------------全局变量结束-------------

//==================初始化开始================
/*
  document.onkeydown=subEv;
*/
$j(function (){
	//$j(document).bind("keydown",subEv);
})

$j(function (){
	$('stumsc_textarea_bs').disabled = true;
	$('stumsc_submit_button_bs').disabled = true;
	
})
var web_url="/";
function errpic(thepic){
thepic.src="<%=request.getContextPath()%>/images/nobody.jpg"; 
}


//------------------初始化结束-------------





//=================自定义函数开始===============
//属于tabcard.js里的方法，在单击tab时触发
function mSearch(obj){
	if(stuno_bs != null){
		switch(obj.id){
			case "basicInfo_bs" : studentAction.getStudentBasicInfo(stuno_bs,studentdormitorytype,stu_BasicInfoCallback);break;
			case "dormHistory_bs" : studentAction.getStudentHistoryAccomodationInfo(stuno_bs,studentdormitorytype,stu_HistoryAccomodationInfoCallback);break;
			case "chargeInfo_bs" : studentAction.getStudentChargeRecord(stuno_bs,studentdormitorytype,getStudentChargeRecordCallback);break;
			case "dormRate_bs": searchDormitoryRateStatus();break;
			case "stuMsc_bs" : studentAction.getStudentBasicInfo(stuno_bs,studentdormitorytype,stu_BasicInfoCallback_msc);break;
		}
	}
	
}
//验证输入是否有效
function validate_bs(){
	stuno_bs = strTrim_cv($('student_info').value);
	if(stuno_bs == ""){
			alert("请输入学号！");
			return false;
	}
	if(!cnChar_cv(stuno_bs)){
			alert("您只能输入数字,字母和汉字,请重新输入");
			return false;
	}
	return true;
}
//搜索学生信息
//对外的接口方法
function stu_BasicInfo(){
	
	var b = validate_bs();
	if(false == b){
		return ;
	}
	//mSearch()本是tabcard.js中调用的方法,这里调用它,判断当前激活的tab,并触发相关的方法
	mSearch($j('.active').get(0))
}
var stu_BasicInfoCallback = function stu_BasicInfoCallbackFunc(stulist){
	$('notExist').style.display = 'none';
	if(stulist == null){
		$('notExist').style.display = '';
		return;
	}
	//alert(stulist.length+"====="+stulist);
	var slist = stulist;
	if($('studentno') != null){
		$('studentno').value = slist[1];
	}
	$('student_id').innerHTML = slist[0]; //加上了隐藏的学生id
	$('stuNo').innerHTML = slist[1];
	$('stuName').innerHTML = slist[2];
	$('stuGender').innerHTML = slist[3];
	$('stuCollege').innerHTML = slist[4];
	$('stuMajor').innerHTML = slist[5];
	$('stuClass').innerHTML = slist[6];
	$('stuDorm').innerHTML = slist[7];
	$('stuPhone').innerHTML = slist[8];
	$('studentpicture').src="<%=request.getContextPath()%>"+slist[9];
	$('stuEthnic').innerHTML = slist[10];
	$('stuBirthplace').innerHTML = slist[11];
	$('stuBirthday').innerHTML = slist[12];
	$('stuType').innerHTML = slist[13];
	$('student_preassignid').innerHTML = slist[14]; 
	$('stuStartTime').innerHTML = slist[16]; 
	$('stuEndOutTime').innerHTML = slist[17]; 
	
	//alert("=====");
	
}

//返回学生的备注信息
var stu_BasicInfoCallback_msc =  function stu_BasicInfoCallback_mscFunc(stulist){
	if(stulist == null){
		return;
	}
	var slist = stulist;
	$('stumsc_textarea_bs').value = slist[15];
	$('stumsc_textarea_bs').disabled = true;
	$('stumsc_edit_button_bs').disabled = false;
	$('stumsc_submit_button_bs').disabled = true;
}
//单击“开始编辑”学生备注
function startEditMsc_bs(){
	$('stumsc_edit_button_bs').disabled = true;
	$('stumsc_submit_button_bs').disabled = false;
	$('stumsc_textarea_bs').disabled = false;
	$('stumsc_textarea_bs').select();
}
//单击“提交修改”学生备注
function submitModify_bs(){
	
	studentAction.editStuMsc($('stumsc_textarea_bs').value,stuno_bs,function (flag){
		if(flag == true){
			alert("更新备注成功！");
			$('stumsc_edit_button_bs').disabled = false;
			$('stumsc_submit_button_bs').disabled = true;
			$('stumsc_textarea_bs').disabled = true;
		}else{
			alert("系统忙，请稍后再试");
		}
	});	
	
}
//返回的historyAccomodationRecordList是二维数组
var stu_HistoryAccomodationInfoCallback=function stu_HistoryAccomodationInfoCallbackFunc(historyAccomodationRecordList){
	
	//删除为查询历史住宿信息生成的动态表格
	//表格有一个头部,所以第一行不删
	for(var i=$('student_accomodation_history').rows.length-1;i>0;i--){ 
       	$('student_accomodation_history').deleteRow(i); 
   	} 
   	//判断历史住宿信息是否为空
   	if(null == historyAccomodationRecordList){
   		return;
   	}
   	//动态添加新的记录行
   	var oneHistoryAccomodationRecord;
   	//alert(historyAccomodationRecordList);
   	//oneHistoryAccomodationRecord =  eval('('+historyAccomodationRecordList+')');
	for(var n=0;n<historyAccomodationRecordList.length;n++){
		oneHistoryAccomodationRecord = historyAccomodationRecordList[n];
		//表格有一个头部,所以后面插入的行号要加一
		myrow=$("student_accomodation_history").insertRow(n+1);	
		myrow.id= "tr"+eval(n+1);
		c=myrow.insertCell(0);
		c.innerHTML=oneHistoryAccomodationRecord[2];
		c=myrow.insertCell(1);
		c.innerHTML=oneHistoryAccomodationRecord[0];
		c=myrow.insertCell(2);
		c.innerHTML=oneHistoryAccomodationRecord[1];
	}
}

var getStudentChargeRecordCallback = function getStudentChargeRecordCallbackFunc(list){
	//删除为查询历史交费生成的动态表格
	//表格有一个头部,所以第一行不删
	for(var i=$('student_charge_history').rows.length-1;i>0;i--){ 
       	$('student_charge_history').deleteRow(i); 
   	} 
	
   	//动态添加新的记录行
   	var oneHistoryChargeRecord;
   	if(null == list){
   		return;
   	}
   	//alert(historyAccomodationRecordList);
   	//oneHistoryAccomodationRecord =  eval('('+historyAccomodationRecordList+')');
	for(var n=0;n<list.length;n++){
		oneHistoryChargeRecord = list[n];
		//表格有一个头部,所以后面插入的行号要加一
		myrow=$("student_charge_history").insertRow(n+1);	
		myrow.id= "tr"+eval(n+1);
		c=myrow.insertCell(0);
		c.innerHTML=oneHistoryChargeRecord[2];
		c=myrow.insertCell(1);
		c.innerHTML=(oneHistoryChargeRecord[4]== 1)?"已交费":"未交费";
		c=myrow.insertCell(2);
		c.innerHTML=oneHistoryChargeRecord[3];
	}
}
//enter键按下提交搜索

  function   subEv(event)   {  
	  event = event ? event : (window.event ? window.event : null);    
	  if(event.keyCode==13) {
	  	 stu_BasicInfo();
	  }
   
  } 


function searchDormitoryRateStatus(){
	if(stuno_bs != null && stuno_bs != ""){
		dormitoryStatusViewAction.getDormitoryRateStatus(stuno_bs,studentdormitorytype,searchDormitoryRateStatusCallback);
	}
}
var searchDormitoryRateStatusCallback = function searchDormitoryRateStatusCallbackFunc(list){
	//删除为查询宿舍卫生状况生成的动态表格
	//表格有一个头部,所以第一行不删
	for(var i=$('student_dorm_hygienic').rows.length-1;i>0;i--){ 
       	$('student_dorm_hygienic').deleteRow(i); 
   	} 
   	//判断宿舍卫生状况记录是否为空
   	if(null == list){
   		return;
   	}
	for(var n=0;n<list.length;n++){
		l = list[n];
		//表格有一个头部,所以后面插入的行号要加一
		myrow=$("student_dorm_hygienic").insertRow(n+1);	
		myrow.id= "tr"+eval(n+1);
		c=myrow.insertCell(0);
		c.innerHTML=l[3];
		c=myrow.insertCell(1);
		c.innerHTML=l[2];
		c=myrow.insertCell(2);
		c.innerHTML=l[4];
	}
}	
//输入学号的文本框被聚焦时
function stuno_button_onfocus_func_bs(){
	$j(document).bind("keydown",subEv);
}
//输入学号的文本框焦点离开时
function stuno_button_onblur_func_bs(){
	$j(document).unbind("keydown",subEv);
}
//------------------自定义函数结束---------------------

var callback = function liststudentno(callbackno)
{			
	document.getElementById("student_info").value=callbackno;	
	stu_BasicInfo();
			
}
</script>
<script type="text/javascript" for="DMSCardCtrl" event="OnSwipCard(codeID, carno, usercode,time)">
		{
			cardAction.getStudentNo(carno,callback);
			
		}		
	</script>
	 <object id="DMSCardCtrl" classid="CLSID:C90A7370-60BA-45AE-B0DF-12D8564C4868"></object>
<div id="student_basic_info">
	<div id="student_basic_info_search">
		请输入学号：
		<input name="textfield" type="text" onfocus="stuno_button_onfocus_func_bs()" onblur="stuno_button_onblur_func_bs()" id="student_info"  />
		<input class="common_button" type="submit" name="button" id="button" value="搜索"
			onclick="stu_BasicInfo()" />
	</div>
	<label id="notExist" style="display:none;color:'red';font-weight:bolder;" >学号不存在!</label>
	<div class="tab_card" id="student_basic_info_tab">
		<ul class="menu">
			<li class="active" id="basicInfo_bs">
				基本信息
			</li>
			<li id="dormHistory_bs">
				住宿历史
			</li>
			<li id="chargeInfo_bs">
				交费信息
			</li>
			<li id="dormRate_bs">
				卫生评比
			</li>
			<li id="stuMsc_bs">
				备注
			</li>
		</ul>
		<div class="tab_card_con">
			<div id="student_basic_info_content2">
				<table class="table_student_basic_info">
					<tbody>
						<tr>
							<td rowspan="7">
							<img id="studentpicture" src="<%=request.getContextPath()%>/images/nobody.jpg"
									width="90px" height="120px" alt="头像" onerror="javascript:errpic(this)"/>
							</td>
							<td class="st_td_left">
								学号
							</td>
							<td class="st_td_right_1">
								<!-- 学生id的隐藏在这 -->
								<div id="student_id" style="display: none"></div>
								<!-- 学生预分配id的隐藏在这 -->
								<div id="student_preassignid" style="display: none"></div>
								<div id="stuNo"></div>
							</td>
							<td class="st_td_left">
								学院
							</td>
							<td class="st_td_right">
								<div id="stuCollege"></div>
							</td>
						</tr>
						<tr>
							<td class="st_td_left">
								姓名
							</td>
							<td class="st_td_right_1">
								<div id="stuName"></div>
							</td>
							<td class="st_td_left">
								专业
							</td>
							<td class="st_td_right">
								<div id="stuMajor"></div>
							</td>
						</tr>
						<tr>

							<td class="st_td_left">
								性别
							</td>
							<td class="st_td_right_1">
								<div id="stuGender"></div>
							</td>
							<td class="st_td_left">
								班级
							</td>
							<td class="st_td_right">
								<div id="stuClass"></div>
							</td>
						</tr>
						<tr>
							<td class="st_td_left">
								民族
							</td>
							<td class="st_td_right_1">
								<div id="stuEthnic"></div>
							</td>
							<td class="st_td_left">
								类别
							</td>
							<td class="st_td_right">
								<div id="stuType"></div>
							</td>
						</tr>
						<tr>
							<td class="st_td_left">
								籍贯
							</td>
							<td class="st_td_right_1">
								<div id="stuBirthplace"></div>
							</td>
							<td class="st_td_left">
								宿舍
							</td>
							<td class="st_td_right">
								<div id="stuDorm"></div>
							</td>
						</tr>
						<tr >
							<td class="st_td_left">
								手机
							</td>
							<td class="st_td_right_1">
								<div id="stuPhone"></div>
							</td>
							<td class="st_td_left">
								入住时间
							</td>
							<td class="st_td_right">
								<div id="stuStartTime"></div>
							</td>
							
						</tr>
						<tr >
							<td class="st_td_left">
								生日
							</td>
							<td class="st_td_right_1">
								<div id="stuBirthday"></div>
							</td>
							<td class="st_td_left">
								到期时间
							</td>
							<td class="st_td_right">
								<div id="stuEndOutTime"></div>
							</td>
							
						</tr>
					</tbody>
				</table>
			</div>
			<div id="student_basic_info_content3">
				<table id="student_accomodation_history"
					class="table_student_basic_info">
					<tr>
						<td>
							宿舍号
						</td>
						<td>
							开始入住时间
						</td>
						<td>
							结束入住时间
						</td>
					</tr>
				</table>
			</div>
			<div id="student_basic_info_content4">
				<table id="student_charge_history" class="table_student_basic_info">
					<tr>
						<td>
							交费时间
						</td>
						<td>
							交费状态
						</td>
						<td>
							交费金额
						</td>
					</tr>
				</table>
			</div>
			<div id="student_basic_info_content5">
				<table id="student_dorm_hygienic"
					class="table_student_basic_info">
					<tr>
						<td>
							评分时间
						</td>
						<td>
							分数
						</td>
						<td>
							评分人
						</td>
					</tr>
				</table>
			</div>
			<div id="student_basic_info_content6">
				<table id="student_msc_bs"
					class="table_student_basic_info">
					<tr>
						<td>
							备注：
							<div>
								<textarea  id="stumsc_textarea_bs" rows="3" cols="51" >
								</textarea>
							</div>
							<div>
								<input type="button" id="stumsc_edit_button_bs" value="开始编辑" onclick="startEditMsc_bs()"/>
								<input type="button" id="stumsc_submit_button_bs" value="提交修改" onclick="submitModify_bs()" />
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<script language="javascript">
            
            /**
             *
             * @param string tabId			当前标签组id
             * @param string fromContendId	要加载的内容的id前缀
             * @param int bindType	绑定方式 0为绑定鼠标移上效果 1为鼠标点击的效果
             * @version 1.0.0
             */
            //TabCard(tabId,fromContendId,bindType)
            var tmpObj1 = new TabCard("student_basic_info_tab", "student_basic_info_content", 1);
            tmpObj1.mActiveClass = "active";
            tmpObj1.mNoActiveClass = "default";
            tmpObj1.mListStartNumb = 2;
            tmpObj1.initab();
</script>
<br />
